//inter_2d return interpolated value of y

// fucton prototype
//int16 inter_2d ( int16 x, int16 x1, int16 x2, int16 y1, int16 y2);

typedef enum {
    fuzzy_nb,
    fuzzy_nm,
    fuzzy_ns,
    fuzzy_z,
    fuzzy_ps,
    fuzzy_pm,
    fuzzy_pb,
    fuzzy_count
} fuzzy_set_dim_t;

typedef struct {
    //                  delta err
    signed int16 react[fuzzy_count][fuzzy_count];
    signed int16 err[fuzzy_count];
    signed int16 d_err[fuzzy_count];
} fuzzy_range_t;

signed int16 inter_2d (signed int16 x,
                        signed int16 x1, signed int16 x2,
                        signed int16 y1, signed int16 y2);

signed int16 inter_3d (signed int16 x, signed int16 y,
                        signed int16 x1, signed int16 x2,
                        signed int16 y1, signed int16 y2,
                        signed int16 z11, signed int16 z12,
                        signed int16 z21, signed int16 z22);

signed int16 fuzzy_control (signed int16 current, signed int16 set_point,
                            fuzzy_range_t *range);

void fuzzy_init (fuzzy_range_t *range);

